!function ($) {
	"use strict";
	/**
	 * 默认参数
	 */
	var defaults = {
		"xzqhdm"		 : '440000',
        //业务参数集，参数为function，function的返回值必须为Object格式：{a:1,b:2,……}
        "params"         : undefined,
        //自定义样式
        "className"      : undefined,
        //上下文
        "context"		 : undefined,
        //异步处理分页
        "asyncLoad"      : false,
        //异步处理对象容器，支持使用jquery表达式
        //服务端返回页面模式使用
        "asyncTarget"    : 'body',
        //异步提交方式，默认POST
        "asyncType"      : 'POST',
        //是否使用服务端返回页面的形式
        //该参数仅在异步处理模式下有效（asyncLoad = true）
        "serverSidePage" : false,
        //异步数据模式自定义处理回调，ajax请求服务端并返回json数据后，可使用数据进行自定义页面渲染
        "render"         : undefined,
        //分页跳转URL
        "url"            : '',
        //异步方式分页后，并在返回的页面内容嵌入到指定位置后，执行该回调，跳转方式不执行该回调
        //参数param，插件的参数集
        "callback"       : $.noop
	};
	/**
	 * 模板
	 */
	var template = '<a class="navigation-hall-toggle" href="javascript:void(0);">切换区域和部门 <span class="caret"></span></a>'+
        '<div class="navigation-hall-dropdown picker-hall">'+
        '<i class="picker-hall--close">&times;</i>'+
        '<div class="picker-hall-content">'+
		    '<div class="picker-hall-hd">'+
		      '<ul id="nav" class="picker-hall-nav">'+
		      '</ul>'+
		    '</div>'+
		    '<div class="picker-hall-bd">'+
		      '<ul id="selector" class="picker-hall-selector">'+
		        '<li><a href="javascript:void(0);">广州市</a></li>'+
		      '</ul>'+
		      '<ul id="station" class="picker-hall-station">'+
		      	'<li class="picker-hall-station-line"><a href="javascript:void(0);">广东政务服务网</a></li>'+
		      '</ul>'+
		      '<ul id="windows" class="picker-hall-window">'+
		      	'<li class="picker-hall-window-title">部门窗口</li>'+
		        '<li><a href="javascript:void(0);">省编办</a></li>'+
		      '</ul>'+
		    '</div>'+
    	'</div>'+
    	'</div>';
	/**
	 * 构造方法
	 */
	var HallNav = function(element,p){
		this.$container = element;
		this.p = p;
	};
	/**
	 * 插件常量
	 */
	HallNav.version = '1.1';
	/**
	 * 绑定事件的名称，使用了HallNav的命名空间
	 */
	HallNav.eventName = 'click.HallNav';
	/**
	 * 分厅与导航数据缓存
	 */
	HallNav.cache = {};
	/**
	 * 初始化分页
	 */
	HallNav.prototype.init = function(){
		var self = this,p = this.p,elem = this.$container;
		var htmlstr = template;
		$(elem).append(htmlstr);
		//this.setFunction($('#nav li',$(elem)),p.xzqhdm);
		this.setJumpFunction($('#station li a',$(elem)),p.homePage);
		if(p.asyncLoad) this.actionSwitch(p.xzqhdm,'init');
	};
	/**
	 * 数据填充
	 */
	HallNav.prototype.populate = function(renderData){
		var self = this, elem = this.$container, p = this.p;			
		var dsft = renderData.data.hall;
		var windows = renderData.data.department;
		$(".picker-hall-selector",$(elem)).empty();
		
		var current_data = renderData.data.currentArr;
		var areacode = current_data[current_data.length-1].ORGAREACODE;		
		$.each(current_data,function(i,n){
			if('省直窗口' === n.ORGTYPE||'市级窗口' === n.ORGTYPE||'县级窗口' === n.ORGTYPE){
				return false;
			}
			if(areacode===n.ORGAREACODE){			
				$("#windows").show();
				if(areacode==='440000'){
					$('#station',$(elem)).html('<li class="picker-hall-station-line"><a href="'+p.homePage+'">广东政务服务网</a></li>');
				}else if("村居办事点"===n.ORGTYPE || "镇街办事站"===n.ORGTYPE){
					$('#station',$(elem)).html('<li class="picker-hall-station-line"><a href="'+n.SITES_URL+'">广东政务服务网'+n.ORGSNAME+'办事站</a></li>');
					$("#windows").hide();
				}else{
					$('#station',$(elem)).html('<li class="picker-hall-station-line"><a href="'+n.SITES_URL+'">广东政务服务网'+n.ORGSNAME+'</a></li>');
				}
			}
		});
		
		if(windows.length>0){
			var orgType = windows[0].ORGTYPE; 
			if('省直窗口' === orgType){
				$(".picker-hall-window",$(elem)).empty().append('<li class="picker-hall-window-title">省级部门</li>');
			}else if('市级窗口' === orgType){
				$(".picker-hall-window",$(elem)).empty().append('<li class="picker-hall-window-title">市级部门</li>');
			}else if('县级窗口' === orgType){
				$(".picker-hall-window",$(elem)).empty().append('<li class="picker-hall-window-title">县级部门</li>');
			}
		}else{
			$("#windows").hide();
		}
				
		$.each(dsft,function(i,n){
			if("村居办事点"===n.ORGTYPE){
				var curDsft = $('<li><a href="'+n.SITES_URL+'" title="' + n.ORGSNAME + '">'+n.ORGSNAME+'</a></li>').appendTo($('#selector',$(elem)));
			}else{
				var curDsft = $('<li><a href="javascript:void(0);" title="' + n.ORGSNAME + '">' + n.ORGSNAME + '</a></li>').appendTo($('#selector',$(elem)));
				self.setFunction($(curDsft),n.ORGAREACODE,n.SITES_URL);
			}
		});
		
		$.each(windows,function(i,n){
			var curWindow = $('<li><a href="'+n.SITES_URL+'" title="' + n.ORGSNAME + '">'+n.ORGSNAME+'</a></li>').appendTo($('#windows',$(elem)));
		});		
		loading.hide();

	};
	/**
	 * 设置事件
	 */
	HallNav.prototype.setFunction = function(obj,areacode,url){
		var self = this;
		$(obj).off(HallNav.eventName).on(HallNav.eventName,function(event){
			loading.show();
			self.renderNavAndStation(this,areacode,url);
			self.actionSwitch(areacode);
		});
	};
	HallNav.prototype.setJumpFunction = function(obj,url){
		var self = this,elem = this.$container;
		$(obj).off('click').on('click',function(event){
			window.location.href = url; 
		});
	}
	HallNav.prototype.renderNavAndStation = function(obj,areacode,url){
		var self = this,p = this.p,elem = this.$container;
		if($(obj).parent().is($('#selector',$(elem)))){
			$(obj).appendTo($('#nav',$(elem)));
		}else{
			$(obj).nextAll().remove();
		}		
	}
	/**
	 * 设置服务端请求参数对象（异步使用ajax请求时执行）
	 */
	HallNav.prototype.getParams = function(areacode){
		var param = {}, p = this.p;
		param.regCode = areacode;
		if(p.params && $.isFunction(p.params)){
			var pa = p.params();
			if($.isPlainObject(pa) && !$.isEmptyObject(pa)) param = $.extend({},param ,pa);
		}
		return param;
	};
	/**
	 * 设置页面点击事件处理
	 * event：事件对象
	 * 若pageNumber参数为-1，而设置当前页不处理操作
	 */
	HallNav.prototype.actionSwitch = function(areacode,initFlag){
		var self = this, p = this.p, elem = this.$container;
		//异步刷新页面模式
		if(p.asyncLoad){
			self.areacode = areacode;
			var param = {};
			if(initFlag){
				param = self.getParams(areacode);
			}else{
				param.regCode = areacode; 
			}
			var async = true;
			if(p.async !== undefined && !p.async) async= p.async;
			if(p.serverSidePage){
				$.ajax({
					url : p.url,
					data : param,
					async : async,
					type : p.asyncType,
					dataType : 'text',//使用了html会导致数据读取后，不执行success内部的问题
					success : function(returnData){
						if(self.extractPageInfo(returnData)){
							if($(p.asyncTarget).size()>0) $(p.asyncTarget).empty().html(returnData);
							if(p.callback && $.isFunction(p.callback)) p.callback(param);
							self.populate();
						}
					}
				});
			}else{
				if(HallNav.cache[areacode]){
					self.populate(HallNav.cache[areacode]);
				}else{
					$.ajax({
						url : p.url,
						data : param,
						async : async,
						type : p.asyncType,
						dataType : 'json',
						success : function(returnData){
							var renderData = returnData.data;
							var current_data = renderData.data.currentArr;
							//数据加入缓存
							HallNav.cache[current_data[current_data.length-1].ORGAREACODE] = renderData;							
							if(initFlag)if(p.render && $.isFunction(p.render)) p.render(renderData);
							if(initFlag){
								$.each(current_data,function(i,n){
									if(param.orgCode && i == (current_data.length-1)){
										return false;
									}
									if(!param.orgCode && "440000" == areacode && i == (current_data.length-1)){
										return false;
									}
									var cur = $('<li><a href="javascript:;">'+n.ORGSNAME+'</a></li>').appendTo($('.picker-hall-nav',$(elem)));
									self.setFunction($(cur),n.ORGAREACODE);
								});
							}														
							self.populate(renderData);
						}
					});
				}
			}
		}else{
			//直接跳转模式
			window.location.href = self.setUrl(pageNumber);
		}
	};
	/**
	 * 插件初始化入口
	 */
	function Plugin(p){
		return this.each(function(){
			//参数合并时允许读取在html元素上定义的'data-'系列的参数
			var $this = $(this),
				data = $this.data('HallNav'),
				params = $.extend({}, defaults, $this.data(), typeof p == 'object' && p);
			if(!data) $this.data('HallNav', (data = new HallNav(this,params)));
			if($.isPlainObject(params)) data.init();
		});
	}
	
	
	$.fn.HallNav             = Plugin;
	$.fn.HallNav.Constructor = HallNav;
	
}(window.jQuery);function myBrowser(){
    var userAgent = navigator.userAgent; //取得浏览器的userAgent字符串
    var isOpera = userAgent.indexOf("Opera") > -1;
    if (isOpera) {
        return "Opera"
    }; //判断是否Opera浏览器
    if (userAgent.indexOf("Firefox") > -1) {
        return "FF";
    } //判断是否Firefox浏览器
    if (userAgent.indexOf("Chrome") > -1){
    	return "Chrome";
	}
    if (userAgent.indexOf("Safari") > -1) {
        return "Safari";
    } //判断是否Safari浏览器
    if (userAgent.indexOf("compatible") > -1 && userAgent.indexOf("MSIE") > -1 && !isOpera) {
        return "IE";
    }; //判断是否IE浏览器
}

/**
 * 附件下载
 * @param attachId 附件id
 */
function attachDowmload(attachId){
	$.ajax({
		type : "POST",
		url : ctx+"/attach/download.do",
		data: {attachId:attachId},
		dataType : "json",
		success : function(data) {
			if(data.url){
				var mb = myBrowser();
				if('IE' == mb){
					window.location.href = data.url;
				}else{
					window.open(data.url,"_blank");
				}
			}else{
				alert("获取不到当前附件下载");
			}
		}
	});
}


function window_action(url){
	if(!checkStrIsBlank(url)){
		window.open(url,"_blank");
	}
}

function dsft_action(url){
	if(!checkStrIsBlank(url)){
		window.open(url,"_blank");
	}
}

/**
 * 输入限制，只能输入数字
 * function onkeyup()
 * function onafterpaste()
 */
function onKeyUp(obj){
	if(obj.value.length==1){
		obj.value=obj.value.replace(/[^1-9]/g,'')
	}else{
		obj.value=obj.value.replace(/\D/g,'')
	}
	
}

function onAfterPaste(obj){
	if(obj.value.length==1){
		obj.value=obj.value.replace(/[^1-9]/g,'')
	}else{
		obj.value=obj.value.replace(/\D/g,'')
	}
	
}

/**
检查输入的字符是否具有特殊字符
输入:str  字符串
返回:true 或 flase; true表示包含特殊字符
*/
function checkQuote(str) {
    var items = new Array("~", "`", "!", "@", "#", "$", "%", "^", "&", "{", "}", "[", "]", "(", ")");
    items.push(":", ";", "'", "|", "\\", "<", ">", "?", "/", "<<", ">>", "||" ,"\"");
    items.push("+", "_" ,"*");
    str = str + "";
    for (var i = 0; i < items.length; i++) {
        if (str.indexOf(items[i]) >= 0) {
            return true;
        }
    }
    return false;
}


/**
 * 在线申办跳转
 * @param url 在线申办地址
 */
function zxsb_action(url){
	window.open(url,"_blank");
}

/**
 * 搜索选项切换
 * @param obj
 */
function ssfw(obj){
	$(".sel-on").removeClass("sel-on gradient-light-blue").removeAttr("aria-pressed");
	$(obj).addClass("sel-on gradient-light-blue").attr("aria-pressed","true");
}

function checkXzqhJb(xzqh){
	var xzqhArr = xzqh.split('');
	var tanslatorStr = '';
	for(var i = 0;i<xzqhArr.length-1;i++){
		if(xzqhArr[i] == '0'){
			if(compareFooter(xzqhArr,i)){
				tanslatorStr = xzqh.substring(0, i);
				break;
			}else{
				continue;
			}
		}
	}
	if(tanslatorStr==''){
		return xzqh;
	}
	return tanslatorStr ;
}

function compareFooter(xzqhArr,i){
	for (var j = i; j < xzqhArr.length; j++) {
		if(xzqhArr[j] != '0'){
			return false;
		}
	}
	return true;
}

function checkStrIsBlank(str){
	if(0 === str) return false;
	if(str){
		if(str != 'null' && str != '' && typeof(str) != undefined){
			return false;
		}
	}
	return true;
}
/**
 * 字符串处理：为空返回空字符串，否则返回字符串本身
 * @param str 待处理字符串
 * @param returnStr 为空时返回的字符串，为空默认返回空字符串
 * @returns 
 */
function handleStr(str, returnStr) {
	if (checkStrIsBlank(str)) {
		if (checkStrIsBlank(returnStr)) {
			return '';
		} else {
			return returnStr;
		}
	} else {
		return str;
	}
}

/**
 * 格式化日期
 * @param fmt 格式，如yyyy-MM-dd
 */
Date.prototype.Format = function (fmt) { //author: meizz 
    var o = {
        "M+": this.getMonth() + 1, //月份 
        "d+": this.getDate(), //日 
        "h+": this.getHours(), //小时 
        "m+": this.getMinutes(), //分 
        "s+": this.getSeconds(), //秒 
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度 
        "S": this.getMilliseconds() //毫秒 
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
    if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
}
/**
 * 根据key值获取url参数
 * @param key
 * @param win 窗口对象
 */
function getQueryString(key, win) {
	var reg = new RegExp("(^|&)" + key + "=([^&]*)(&|$)", "i");
	var r = win.location.search.substr(1).match(reg);
	if (r != null) {
		return unescape(r[2]);
	}
	return null;
}
/**
 * 改变头部tab签hover态
 * @param index tab索引（整型数字），起始值0
 */
function changeHeaderNavHover(index) {
	if (!checkStrIsBlank(index)) {
		$(".navigation li").removeClass("active");
		$($(".navigation li")[index]).addClass("active");
	}
}

//去掉字符串中所有空格(包括中间空格,需要设置第2个参数为:g) 
function trim(str,is_global){
    var result;
    result = str.replace(/(^\s+)|(\s+$)/g,"");
    if(is_global.toLowerCase()=="g"){
        result = result.replace(/\s/g,"");
     }
    return result;
}
/**
 * 空列表提示信息html生成
 * @param content 空列表提示内容
 * @returns 空列表提示信息
 */
function emptyListHtml(content) {
	if (!content) {
		content = '当前条件下没有相关信息';
	}
	var html = '<div class="placeholder placeholder-empty"><div class="placeholder-bd">';
	html += '<div class="placeholder-bd"><div class="placeholder-icon"></div>';
	html += '<div class="placeholder-title">'+content+'</div></div></div></div>';
	return html;
}
/**
 * 提示加载中html生成
 * @param content
 * @returns {String}
 */
function loadingHtml(content) {
	if (!content) {
		content = '正在加载';
	}
	var html = '<div class="placeholder placeholder-loading"><div class="placeholder-bd">';
	html += '<div class="placeholder-icon">';
	html += '</div><div class="placeholder-title">'+content+'</div></div></div>';
	return html;
}
/**
 * 用户登录
 * @returns
 */
function login(){
	//方法定义在getLoginInfo.js里
	gotoLogin();
}
/**
 * 退出登录
 * @returns
 */
function logout(){
	confirm({msg:"确定要退出登录吗？", btnOkClick:function(){
		//方法定义在getLoginInfo.js里
		gotoLogout();
	}});
}

function getLocationAdvice(callback){
	$.ajax({
		type : "GET",
		url : ctx+"/api/ip/location",
		//timeout : 5000,
		dataType: 'json',
		success: function(data){
			if(data.statusCode != "200" || !data.data || data.data.status !=0 ){
				console && console.log("ip定位失败")
				callback({
					areaName: '广东省',
					areaCode: '440000'
				})
				return;
			}
			data = data.data
			var areaCode = data.result.ad_info.adcode.toString()
			var areaName = data.result.ad_info.city
			if(areaCode.indexOf('44') != 0){
				areaCode = '440000'
				areaName = '广东省'
			}
			if(areaCode == '440000'){
				areaName = '广东省'
			}
			callback({
				areaName: areaName,
				areaCode: areaCode
			})
		},
		error: function(){
				callback({
					areaName: '广东省',
					areaCode: '440000'
				})
			},
		complete:function(XMLHttpRequest,status){ 
		　　　　if(status=='timeout'){
				console && console.log('定位超时!')
		　　　　}
		}
	})
}

//ip location
function getIpLocation(callback){
	var location = sessionStorage && sessionStorage.getItem('ip.location')
	if(location){
		callback(JSON.parse(location))
		return
	}
	getLocationAdvice(function(data){
		sessionStorage && sessionStorage.setItem('ip.location',JSON.stringify(data))
		callback(data)
	})
}
/**
 * 分页控件返回数据时创建默认对象
 */
function createDefaultObject() {
	var obj = new Object();
	obj.page = 1;
	obj.pageSize = 10;
	obj.totalCount = 0;
	obj.result = '';
	return obj;
}
/**
 * 个性化接口返回数据为空或不符合要求处理
 */
function handleErrorCustomConfig() {
	
}
/**
 * 关闭窗口
 */
function closeWindow() {
	window.close();
	window.history.go(-1);
}

/**
 * 单点跳转
 * @param url	跳转链接
 */
function sso(url){
	var ssoUrl = getSSOUrl(url)
	var win = window.open(ssoUrl,"_blank");
	win.opener=null;
}

function getSSOUrl(url){
	if(!url) {
		return;
	}
	if(!gdbsTokenId){
		gdbsTokenId = '';
	}
	if(url.indexOf("?") > 0) {
		url += "&gdbsTokenId=" + gdbsTokenId;
	} else {
		url += "?gdbsTokenId=" + gdbsTokenId;
	}
	return url
}

$(document).ready(function(){
$("#navigationHall").HallNav({
	url : ctx+"/custom-config/gdbsNav/current",
    asyncLoad : true,
    homePage:ctx+'/index',
    context:ctx,
    xzqhdm:region,
    //关闭服务端页面模式
    serverSidePage : false,
  	//数据自定义填充
    render : function(data){
    	if(data){
    		
    		var current = data.data.currentArr;
        	var header_title = '广东省';
        	if(system_type == 'product'){
        		var sites_url = '//www.gdzwfw.gov.cn'
        	}else {
        		var sites_url = ctx+'/index';
        	}
        	
        	
        	if(current && current.length>0 && current[current.length-1].ORGAREACODE!='440000'){
        		var headerTitle = '';
        		var headerUrl = '';
        		$.each(current,function(i,n){
        			if(n.ORGTYPE === '市分厅' && n.ORGAREACODE!='440000'){
        				headerTitle += n.ORGSNAME;
        				headerUrl = '?region=' + n.ORGAREACODE;
        			}else if(n.ORGTYPE === '区县分厅'){
        				headerTitle += n.ORGSNAME;
        				headerUrl = '?region=' + n.ORGAREACODE;
        			}
        		});
        		header_title = headerTitle;
        		sites_url += headerUrl;
        		
        		var orgname = current[current.length-1].ORGNAME;
        		var orgareacode = current[current.length-1].ORGAREACODE;        		
        		// 同时写入部门窗口banner区和隐藏标签名称框
        		var bannerTitleObj = $(".banner-hall-title");
        		if(bannerTitleObj && checkStrIsBlank($(bannerTitleObj).html())) {
        			$(bannerTitleObj).html(orgname);
        		}
        		var inputTitleObj = $("#input-title");
        		if (inputTitleObj && checkStrIsBlank($(inputTitleObj).val())) {
        			document.title = orgname + "窗口";
        		}      			       		
        	}
        	
        	if(!checkStrIsBlank(getQueryString("orgCode",window))){ //如果是orgCode，则需要通过orgCode解析出region
        		getCustomConfig('gdbsPortal/common',{region:orgareacode},commonRender);
        	}
        	$("#headerTitle").html('<a href="'+sites_url+'">'+header_title+'</a>');
    	}
    },
    //自定义传递到服务端的参数
    params : function(){
    	var params = {};
    	if(orgCode){
    		params.orgCode = orgCode;
    	}
        return params;
    }
});
})//前端异步获取登录信息
$(function(){
	//获取登录信息
	$.ajax({
		url: "/_tif_sso_loginuser_get/",
		method: "POST",
		success:function(result){
			if(result && result.errcode=="0") {
				var user = result.data;
				var name = user.name;
				var level = user.level;
				var userType = "个人";
				var currentlogin = "";
         		
         		//如果有父账号，显示父账号名称
         		if(user.corp) {
         			currentlogin = "当前登录："+user.name;
         			level = user.corp.level;
         			name = user.corp.name;
         			userType = "企业";
         		}
         		//企业账号
         		if(user.account_type == 'corp') {
         			userType = "企业";
         		}
         		
         		//消息通知
         		var personal_html = '<li id="login-li" class="gd-md-hide">' +
         							'<a href="'+xxzxUrl+'" rel="noopenner noreferrer" id="userpanel-notification" class="gd-userpanel-notification" title="消息通知"></a></li>' +
         							'<li><div class="gd-userpanel gd-userpanel-personal">' +
         							'<a href="javascript:;" class="gd-userpanel-toggle"><span>{name}</span></a>' +
         							'<ul class="gd-userpanel-dropdown">' +
         							'<li class="gd-userpanel-username">' +
         							'<span class="gd-userpanel-name">{name}</span>' +
         							'<span class="gd-userpanel-level">{userLevel}</span>' +
         							'<span class="gd-userpanel-currentlogin">{currentlogin}</span>' +
         							'</li>'+
         							'<li class="gd-userpanel-ucenter">' +
         							'<a href="'+grzxUrl+'" rel="noopenner noreferrer">{userType}中心</a></li>'+
         							'<li class="gd-userpanel-manage"><a href="'+zhglUrl+'" rel="noopenner noreferrer">账户管理</a></li>' +
         							'<li class="gd-userpanel-logout"><a href="javascript:;" onclick="gotoLogout()">退出登录</a></li>' +
         							'</ul></div></li>';
				//首页
         		$(".loginUserNameWithCommaSpan").html(name+"，");
         		//右上角登录框
         		personal_html = personal_html.replace(/{userType}/g, userType)
         									 .replace(/{userLevel}/g, level)
         									 .replace(/{name}/g, name)
         									 .replace(/{currentlogin}/g, currentlogin);
         		var login = $("#login-li");
         		login.after(personal_html);
         		login.remove();
         		//移动端登录按钮
         		document.getElementById("login_mobile_button").removeEventListener("click", function(){}, false);         		
         		$("#login_mobile_button").click(function(){
         			location.href = grzxUrl;
         		});
         		//保存用户对象
         		loginInfo = user;
         		//获取消息中心通知数量
         		getUserCenterCount();
			}
		}
	});
});

function getUserCenterCount() {
	if(typeof(loginInfo) == 'undefined' || typeof(xxzxCountUrl) == 'undefined' || !xxzxCountUrl) {
		console && console.log("用户中心地址缺失");
		return;
	}
	$.ajax({
		url: xxzxCountUrl,
		type: "POST",
		data: {
			flag : 0
		},
		success: function(result){
			try{
				if(result && result.errcode == '0' && result.data.count > 0) {
					var count = result.data.count;
					if(count > 99){
						$("#userpanel-notification").append("<span>"+99+"+</span>");
					} else {
						$("#userpanel-notification").append("<span>"+count+"</span>");
					}
				}
			} catch(err) {
				console && console.log("用户中心通知数量获取失败："+err.message);
			}
		},
        error: function (status) {
        	console && console.log("用户中心通知数量获取失败："+status);
        }
	});
}

function gotoLogin() {
	//paasid定义在头文件
	//var paasid = location.pathname.split('/')[1];
	if(typeof(paasid) == 'undefined' || !paasid) {
		var paasid = location.pathname.split('/')[1];
	}
	var selfUrl = location.pathname+location.search+location.hash;
	var gotoUrl = '/_in_/?r=' + encodeURIComponent(selfUrl) + '&p=portal';
	location.href = gotoUrl;
}

function gotoLogout() {
	//paasid定义在头文件
	//var paasid = location.pathname.split('/')[1];
	if(typeof(paasid) == 'undefined' || !paasid) {
		var paasid = location.pathname.split('/')[1];
	}
	var selfUrl = location.pathname + location.search + location.hash;
	var logoutUrl = '/_out_/?p=portal&r=' + encodeURIComponent(selfUrl); 
	location.href = logoutUrl;
}